<template>
	<view class="content" :style="'background: url('+ c_imgPath + 'mine/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
		<view class="header">
			<view class="nav">
				<view class="item" :class="nav_id == 1?'item_sel':''" @click="setNavId(1)">抽赏订单</view>
				<view class="item" :class="nav_id == 2?'item_sel':''" @click="setNavId(2)">商城订单</view>
			</view>
			<view class="qiehuan">
				<view @click="getlist(i+1)" v-for="(v,i) in arr" :key="i">
					<view :class="show==i+1?'xzs':'wzs'">{{v}}</view>
					<view class="qiehuan_line" v-if="show==i+1">
						<image :src="c_imgPath+'mine/text_bom.png'"></image>
					</view>
				</view>
			</view>
		</view>
		<!-- 内容 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<view v-if="nav_id == 1">
				<view class="xuyuan" v-for="(v,i) in listData" :key='i' v-if="listData.length>0">
					<view class="xuyuan_head">
						<view>申请时间：{{v.addtime}}</view>
						<view style="color: #B07CDD;" v-if="v.status==1">待发货</view>
						<view style="color: #B07CDD;" v-if="v.status==2">待收货</view>
						<view style="color: #B07CDD;" v-if="v.status==3">已完成</view>
					</view>
					<view class="xuyuan_con">
						<view class="xuyuan_item" v-for="(a,b) in v.order_list" :key="b">
							<view class="list_img">
								<image :src="a.goodslist_imgurl"></image>
								<view class="shang_title">{{a.shang_name}}</view>
								<view class="allNum">X{{a.prize_num}}</view>
							</view>
							<view class="xuyuan_item_2 flex_center hang1">
								<view class="hang1">{{a.goodslist_title}}</view>
							</view>
						</view>
					</view>
					<view class="xuyuan_foot">
						<view class="qrsh"
							:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'"
							v-if="v.status==1" @click="toorder(v.id)">查看详情</view>

						<template v-if="v.status==2">
							<view class="ckwl" @click="toorder(v.id)"
								:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								查看详情</view>
							<view class="ckwl" @click="towuliu(v.id)"
								:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								查看物流</view>
							<view class="qrsh" @click="quren(v.id)"
								:style="'background: url('+ c_imgPath + 'mine/shouhuo_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								确认收货</view>
						</template>
						<view class="detail_gray" v-if="v.status==3" @click="toorder(v.id)"
							:style="'background: url('+ c_imgPath + 'mine/shouhuo_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
							查看详情</view>

					</view>
				</view>
			</view>
			<view v-if="nav_id == 2">
				<view class="xuyuan" v-for="(v,i) in listData" :key='i' v-if="listData.length>0">
					<view class="xuyuan_head">
						<view>申请时间：{{v.addtime}}</view>
						<view style="color: #B07CDD;" v-if="v.status==1">待发货</view>
						<view style="color: #B07CDD;" v-if="v.status==2">待收货</view>
						<view style="color: #B07CDD;" v-if="v.status==3">已完成</view>
					</view>
					<view class="xuyuan_con">
						<view class="xuyuan_item">
							<view class="list_img">
								<image :src="v.goods_info.goods_image"></image>
								<view class="allNum">X{{v.goods_info.goods_num}}</view>
							</view>
							<view class="xuyuan_item_2 flex_center hang1">
								<view class="hang1">{{v.goods_info.goods_name}}</view>
							</view>
						</view>
					</view>
					<view class="xuyuan_foot">
						<view class="qrsh"
							:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'"
							v-if="v.status==1" @click="toorder(v.order_no)">查看详情</view>

						<template v-if="v.status==2">
							<view class="ckwl" @click="toorder(v.order_no)"
								:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								查看详情</view>
							<view class="ckwl" @click="towuliu(v.id)"
								:style="'background: url('+ c_imgPath + 'mine/detail_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								查看物流</view>
							<view class="qrsh" @click="quren1(v.order_no)"
								:style="'background: url('+ c_imgPath + 'mine/shouhuo_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
								确认收货</view>
						</template>
						<view class="detail_gray" v-if="v.status==3" @click="toorder(v.order_no)"
							:style="'background: url('+ c_imgPath + 'mine/shouhuo_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
							查看详情</view>

					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				z_imgPath: this.$z_img,
				c_imgPath: 'https://qt.yhemall.com/',
				arr: ['已申请', '已发货', '已完成'],
				show: 1,

				downOption: {
					auto: false
				},

				listData: [],

				nav_id: 1

			}
		},
		onLoad(e) {

		},
		methods: {
			setNavId(id) {
				this.nav_id = id;
				this.mescroll.resetUpScroll()
			},
			quren(e) {
				let that = this;
				that.req({
					url: 'warehouse_send_confirm',
					data: {
						id: e
					},
					success(res) {
						if (res.status == 1) {
							uni.showToast({
								title: res.msg,
								icon: 'success',
								duration: 1500,
								success() {
									setTimeout(() => {
										that.loadData(1)
									}, 1000)
								}
							})
						}
					}
				})
			},
			quren1(e) {
				let that = this;
				that.req({
					url: 'integral_order_confirm',
					data: {
						order_no: e
					},
					success(res) {
						if (res.status == 1) {
							uni.showToast({
								title: res.msg,
								icon: 'success',
								duration: 1500,
								success() {
									setTimeout(() => {
										that.loadData(1)
									}, 1000)
								}
							})
						}
					}
				})
			},
			toorder(e) {
				if (this.nav_id == 1) {
					uni.navigateTo({
						url: 'order?id=' + e
					})
				} else {
					uni.navigateTo({
						url: '/pages/shop/order?id=' + e
					})
				}
			},
			towuliu(e) {
				if (this.nav_id == 1) {
					uni.navigateTo({
						url: 'wuliu_detail?id=' + e
					})
				} else {
					uni.navigateTo({
						url: '/pages/shop/wuliu?id=' + e
					})
				}
			},
			getlist(v) {
				this.show = v;
				this.listData = []
				this.mescroll.resetUpScroll()
			},

			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				this.loadData(page.num);
			},
			loadData(pageNo) {
				let that = this;
				var url = '';
				if (this.nav_id == 1) {
					url = 'warehouse_send_record'
				} else {
					url = 'integral_order_list'
				}
				that.req({
					url: url,
					Loading: true,
					data: {
						page: pageNo,
						status: that.show
					},
					success(res) {
						that.mescroll.endByPage(res.data.data.length, res.data.last_page);
						if (pageNo == 1) {
							that.listData = res.data.data;
						} else {
							that.listData = that.listData.concat(res.data.data);
						}

					}
				})
			},


		}
	}
</script>

<style lang="scss">
	.nav {
		display: flex;
		align-items: center;

		.item {
			flex: 1;
			text-align: center;
			padding: 20rpx 0;
			font-size: 32rpx;
			color: #9E99E3;
		}

		.item_sel {
			background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
			-webkit-background-clip: text;
			-webkit-text-fill-color: transparent;
			font-weight: bold;
		}
	}

	.allNum {
		position: absolute;
		bottom: 0rpx;
		right: 0rpx;
		font-size: 22rpx;
		background-color: rgba(0, 0, 0, 0.6);
		border-radius: 8rpx 0 0 8rpx;
		color: #fff;
		padding: 5rpx 10rpx;
	}

	.list_img .shang_title {
		position: absolute;
		bottom: 0;
		background: #B07CDD;
		left: 0;
		/* width: 100%; */
		color: #fff;
		font-size: 24rpx;
		/* font-family: 'zcq'; */
		text-align: left;
		padding: 4rpx 10rpx;
		box-sizing: border-box;
		border-top-right-radius: 10rpx;
		border: 1px solid #000000;
	}

	.list_img>image {
		width: 168rpx;
		height: 168rpx;
		border-radius: 10rpx 10rpx 0 0;
		margin: 1rpx auto;

	}

	.list_img {
		/* box-shadow: 0px 0px 10rpx 0px rgba(150, 255, 254, 0.7); */
		border-radius: 10rpx;
		box-sizing: border-box;
		width: 170rpx;
		height: 170rpx;
		position: relative;
	}

	/* .detail_gray {
		background: #96FFFE;
		color: #222222;
	}

	.ckwl {
		border: 1rpx solid #96FFFE;
		color: #96FFFE;
		margin-right: 20rpx;
	}

	.qrsh {
		background: #96FFFE;
		color: #222222;
	} */

	.xuyuan_foot>view {
		width: 198rpx;
		height: 58rpx;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #FFFFFF;
	}

	.xuyuan_foot {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		padding: 30rpx;
		font-size: 24rpx;
	}

	.xuyuan_item_2 {
		color: #FFFFFF;
		font-size: 24rpx;
		width: 100%;
		margin-top: 10rpx;
	}

	.xuyuan_item>image {
		width: 170rpx;
		height: 170rpx;
		border-radius: 10rpx 10rpx 0 0;
	}

	.xuyuan_item {
		width: 170rpx !important;
		min-width: 170rpx;
		height: 242rpx;
		border-radius: 10rpx;
		margin-right: 20rpx;
		flex-shrink: 0;
		text-align: center;
	}

	.xuyuan_con {
		display: flex;
		margin: 14rpx auto 0;
		width: 630rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #333333;
		overflow-x: scroll;
	}


	.xuyuan_head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
		color: #999999;
	}

	.xuyuan {
		width: 690rpx;
		/* height: 432rpx; */
		margin: 24rpx auto 0;
		padding-top: 24rpx;
		margin-top: 60rpx;
		box-sizing: border-box;
		/* background: #11141D; */
		border: 1px solid #fff;
		border-radius: 10rpx;
		/* box-shadow: 0px 0px 10rpx 0px rgba(150, 255, 254, 0.7); */
		background: #0A091A;
	}

	.qiehuan {
		display: flex;
		justify-content: space-between;
		/* align-items: center; */
		margin-top: 16rpx;
		width: 400rpx;
	}

	.qiehuan_line {}

	.qiehuan_line>image {
		width: 94rpx;
		height: 24rpx;
	}

	.qiehuan>view {
		flex: 1;
		text-align: center;
	}

	.wzs {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #9E99E3;
	}

	.xzs {
		font-size: 32rpx;
		background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		font-weight: bold;

	}

	.header {
		width: 750rpx;
		/* height: 176rpx; */
		padding-bottom: 30rpx;
		background: #09081C;
		font-size: 28rpx;
		color: #333333;
		box-sizing: border-box;
		position: fixed;
		/* #ifdef MP */
		top: 0;
		/* #endif */
		/* #ifndef MP */
		top: 88rpx;
		/* #endif */
		z-index: 15;
	}


	.content {
		width: 100vw;
		min-height: 100vh;
		padding-top: 170rpx;
		background: #09081C;
		box-sizing: border-box;
	}
</style>